/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package towerdefence.model.color;

import java.awt.Color;

/**
 *
 * @author Gussoh
 */
public class RandomColorCreator extends ColorCreator {

    private int r;
    private int g;
    private int b;
    
    
    @Override
    protected void construct() {
        r = random.nextInt(256);
        g = r += Math.signum(random.nextDouble() - .5) * 100 + random.nextInt(50);
        g = g % 256;
        b = g += Math.signum(random.nextDouble() - .5) * 75 + random.nextInt(50);
        b = b % 256;
    }
    
    @Override
    public Color getNextColor() {
        int tr, tg, tb;
        int posOrNeg = 1;
        if(random.nextBoolean()) {
            posOrNeg = -1;
        }
        
        tr = r += posOrNeg * 100 + random.nextInt(30);
        tr *= Math.signum(tr);
        tr = tr % 256;
        
        tg = g += (-posOrNeg) * 100 + random.nextInt(30);
        tg *= Math.signum(tg);
        tg = tg % 256;
        
        tb = b += 60 + random.nextInt(30);
        tb *= Math.signum(tb);
        tb = tb % 256;
        
        return new Color(tr, tg, tb);
    }
}
